package com.dingqb.ktdemo.oop
/**
abstract    // 抽象类
final       // 类不可继承，默认属性
enum        // 枚举类
open        // 类可继承，类默认是final的
annotation  // 注解类
 **/

fun main(args: Array<String>) {
    var obj: Class_obj = Class_obj("name-tom", "age-18");
    obj.nameP = "1aAbc";
    obj.age = -10;
    println(obj.nameP)
    println(obj.age)

}


class Class_obj {
    constructor(name: String, age: String) : this(name) {
        println("constructor")
    }

    constructor(nameP: String) {
        println("constructor main")
    }

    var nameP: String = ""
        get() = field;
        set(value) {
            field = value + "->Uppercase:" + value.toUpperCase();
        }
    var age: Int = 0
        get() = field
        set(value) {
            field = if (value < 0) 0 else value
        }


    init {
        println("init");
    }
}